﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGeNurbSurface : OdGeSurface
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGeNurbSurface(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGeNurbSurface_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGeNurbSurface obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGeNurbSurface()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGeNurbSurface(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdGeNurbSurface() : this(GlobalsPINVOKE.new_OdGeNurbSurface__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeNurbSurface(int degreeInU, int degreeInV, int propsInU, int propsInV, int numControlPointsInU, int numControlPointsInV, OdGePoint3dArray controlPoints, OdGeDoubleArray weights, OdGeKnotVector uKnots, OdGeKnotVector vKnots, OdGeTol tol) : this(GlobalsPINVOKE.new_OdGeNurbSurface__SWIG_1(degreeInU, degreeInV, propsInU, propsInV, numControlPointsInU, numControlPointsInV, OdGePoint3dArray.getCPtr(controlPoints), OdGeDoubleArray.getCPtr(weights), OdGeKnotVector.getCPtr(uKnots), OdGeKnotVector.getCPtr(vKnots), OdGeTol.getCPtr(tol)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeNurbSurface(int degreeInU, int degreeInV, int propsInU, int propsInV, int numControlPointsInU, int numControlPointsInV, OdGePoint3dArray controlPoints, OdGeDoubleArray weights, OdGeKnotVector uKnots, OdGeKnotVector vKnots) : this(GlobalsPINVOKE.new_OdGeNurbSurface__SWIG_2(degreeInU, degreeInV, propsInU, propsInV, numControlPointsInU, numControlPointsInV, OdGePoint3dArray.getCPtr(controlPoints), OdGeDoubleArray.getCPtr(weights), OdGeKnotVector.getCPtr(uKnots), OdGeKnotVector.getCPtr(vKnots)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeNurbSurface(OdGeNurbSurface source) : this(GlobalsPINVOKE.new_OdGeNurbSurface__SWIG_3(OdGeNurbSurface.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeNurbSurface Assign(OdGeNurbSurface nurb)
		{
			OdGeNurbSurface result = new OdGeNurbSurface(GlobalsPINVOKE.OdGeNurbSurface_Assign(this.swigCPtr, OdGeNurbSurface.getCPtr(nurb)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isRationalInU()
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_isRationalInU(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isPeriodicInU(out double period)
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_isPeriodicInU(this.swigCPtr, out period);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isRationalInV()
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_isRationalInV(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isPeriodicInV(out double period)
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_isPeriodicInV(this.swigCPtr, out period);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int singularityInU()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_singularityInU(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int singularityInV()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_singularityInV(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int degreeInU()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_degreeInU(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int numControlPointsInU()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_numControlPointsInU(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int degreeInV()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_degreeInV(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int numControlPointsInV()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_numControlPointsInV(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getControlPoints(OdGePoint3dArray controlPoints)
		{
			GlobalsPINVOKE.OdGeNurbSurface_getControlPoints(this.swigCPtr, OdGePoint3dArray.getCPtr(controlPoints));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool getWeights(OdGeDoubleArray weights)
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_getWeights(this.swigCPtr, OdGeDoubleArray.getCPtr(weights));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int numKnotsInU()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_numKnotsInU(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getUKnots(OdGeKnotVector uKnots)
		{
			GlobalsPINVOKE.OdGeNurbSurface_getUKnots(this.swigCPtr, OdGeKnotVector.getCPtr(uKnots));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public int numKnotsInV()
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_numKnotsInV(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getVKnots(OdGeKnotVector vKnots)
		{
			GlobalsPINVOKE.OdGeNurbSurface_getVKnots(this.swigCPtr, OdGeKnotVector.getCPtr(vKnots));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getDefinition(out int degreeInU, out int degreeInV, out int propsInU, out int propsInV, out int numControlPointsInU, out int numControlPointsInV, OdGePoint3dArray controlPoints, OdGeDoubleArray weights, OdGeKnotVector uKnots, OdGeKnotVector vKnots)
		{
			GlobalsPINVOKE.OdGeNurbSurface_getDefinition(this.swigCPtr, out degreeInU, out degreeInV, out propsInU, out propsInV, out numControlPointsInU, out numControlPointsInV, OdGePoint3dArray.getCPtr(controlPoints), OdGeDoubleArray.getCPtr(weights), OdGeKnotVector.getCPtr(uKnots), OdGeKnotVector.getCPtr(vKnots));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeNurbSurface set(int degreeInU, int degreeInV, int propsInU, int propsInV, int numControlPointsInU, int numControlPointsInV, OdGePoint3dArray controlPoints, OdGeDoubleArray weights, OdGeKnotVector uKnots, OdGeKnotVector vKnots, OdGeTol tol)
		{
			OdGeNurbSurface result = new OdGeNurbSurface(GlobalsPINVOKE.OdGeNurbSurface_set__SWIG_0(this.swigCPtr, degreeInU, degreeInV, propsInU, propsInV, numControlPointsInU, numControlPointsInV, OdGePoint3dArray.getCPtr(controlPoints), OdGeDoubleArray.getCPtr(weights), OdGeKnotVector.getCPtr(uKnots), OdGeKnotVector.getCPtr(vKnots), OdGeTol.getCPtr(tol)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeNurbSurface set(int degreeInU, int degreeInV, int propsInU, int propsInV, int numControlPointsInU, int numControlPointsInV, OdGePoint3dArray controlPoints, OdGeDoubleArray weights, OdGeKnotVector uKnots, OdGeKnotVector vKnots)
		{
			OdGeNurbSurface result = new OdGeNurbSurface(GlobalsPINVOKE.OdGeNurbSurface_set__SWIG_1(this.swigCPtr, degreeInU, degreeInV, propsInU, propsInV, numControlPointsInU, numControlPointsInV, OdGePoint3dArray.getCPtr(controlPoints), OdGeDoubleArray.getCPtr(weights), OdGeKnotVector.getCPtr(uKnots), OdGeKnotVector.getCPtr(vKnots)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void computeVIsoLine(double V, OdGeNurbCurve3d isoline)
		{
			GlobalsPINVOKE.OdGeNurbSurface_computeVIsoLine(this.swigCPtr, V, OdGeNurbCurve3d.getCPtr(isoline));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void computeUIsoLine(double U, OdGeNurbCurve3d isoline)
		{
			GlobalsPINVOKE.OdGeNurbSurface_computeUIsoLine(this.swigCPtr, U, OdGeNurbCurve3d.getCPtr(isoline));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint2d paramOfPrec(OdGePoint3d point, OdGeTol tol)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGeNurbSurface_paramOfPrec__SWIG_0(this.swigCPtr, OdGePoint3d.getCPtr(point), OdGeTol.getCPtr(tol)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d paramOfPrec(OdGePoint3d point)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGeNurbSurface_paramOfPrec__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(point)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int loc(int i, int j)
		{
			int result = GlobalsPINVOKE.OdGeNurbSurface_loc(this.swigCPtr, i, j);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool getDerivativesAtWr(OdGePoint2d param, uint numDeriv, VectorDerivArrayWr derivatives)
		{
			bool result = GlobalsPINVOKE.OdGeNurbSurface_getDerivativesAtWr(this.swigCPtr, OdGePoint2d.getCPtr(param), numDeriv, VectorDerivArrayWr.getCPtr(derivatives));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
